<!DOCTYPE HTML>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport"
		content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,aItemress=no">
	<title>商城-登录注册</title>
	<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
	<link rel="stylesheet" type="text/css" href="../../css/app.css" />
	<link rel="stylesheet" type="text/css" href="../../css/vant.css" />
	<style type="text/css">
		body {
			background-color: #FFFFFF;
		}

		.btn {
			/*padding: 4.5rem 0.5rem 2rem 0.5rem;
				width: 100%;*/
		}

		#footer {
			position: fixed;
			bottom: 0;
			left: 0;
			width: 100%;
			padding-bottom: 0.2rem;
		}

		.Third_party span {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 0.85rem;
			margin-bottom: 0.2rem;
		}

		.Third_party span img {
			width: 0.45rem;
			height: 0.45rem;
		}

		.register_footer {
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 0.14rem;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: rgba(179, 179, 179, 1);
			line-height: 0.17rem;
		}

		.register_footer img {
			width: 0.9rem;
			height: 0.9rem;
			margin-right: 0.10rem;
			vertical-align: center;
		}

		.agreement span {
			color: #005A93;
		}

		.btn-delete {
			position: absolute;
			width: 1rem;
			right: 0rem;
			top: -.5rem;
			z-index: 20;
		}

		.aui-radio {
			margin: 0 0.2rem 0 0.05rem;
		}

		.aui-bar-nav .aui-pull-left {
			padding: 0 0.25rem;
		}

		.aui-list {
			padding: 0 1.25rem;
		}

		.my-list {
			padding: 0 1.25rem;
			margin-top: 2rem;
			position: relative;
			margin-bottom: .7rem;
		}

		.aui-title {
			font-weight: bolder;
		}

		.aui-list-item- {
			height: 2.75rem;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
		}

		.aui-list-item-label- img {
			width: 1rem;
		}

		.aui-btn-block {
			color: #FFFFFF;
			display: inline-block;
			/*background: linear-gradient(-152deg, #ff00ff, #9b00ff);*/
			/*background: linear-gradient(270deg, #ff00ff, #9471da);*/
			/*background: linear-gradient(270deg, #ee02fd, #9972e6);*/
			/*background:linear-gradient(135deg,rgba(132,229,255,1) 0%,rgba(107,180,255,1) 100%,rgba(122,174,229,1) 100%);*/
			background: linear-gradient(135deg, rgba(132, 229, 255, .29) 0%, rgba(107, 180, 255, .29) 100%, rgba(122, 174, 229, .29) 100%);
			width: 16.25rem;
			height: 2.25rem;
			line-height: 2.25rem;
			margin-left: 50%;
			transform: translateX(-50%);
			text-align: center;
		}

		.aui-btn {
			display: inline-block;
			border-radius: 2.5rem;
		}

		.aui-text-linear {
			position: relative;
			background: linear-gradient(-152deg, #ee02fd, #9972e6);
			background: -webkit-linear-gradient(-152deg, #ee02fd, #9972e6);
			color: transparent;
			-webkit-background-clip: text;
			-webkit-text-fill-color: transparent;
		}

		::placeholder {
			font-size: .75rem;
			color: #BBBBBB;
			font-family: PingFangSC-Regular;
			font-weight: 400;
		}

		.aui-info-item>*,
		.aui-info>* {
			flex: 1;
			display: inline-block;
			font-size: 0.8rem;
		}

		.aui-info .active {
			position: relative;
			background: linear-gradient(-152deg, #ee02fd, #9972e6);
			background: -webkit-linear-gradient(-152deg, #ee02fd, #9972e6);
			color: #222222;
			-webkit-background-clip: text;
			-webkit-text-fill-color: #222222;
		}

		.aui-info .active:after {
			/*position: absolute;
				right: 5px;
				left: 5px;
				bottom: 0px;
				content: '';
				border-bottom: 2px solid #E300FF;*/
		}

		.aui-info .active:after {
			position: absolute;
			right: 5px;
			left: 5px;
			bottom: -10px;
			content: '';
			/*border-bottom: 2px solid #E300FF;*/
		}

		.xieyi {
			position: relative;
			/*bottom: 0.5rem;*/
			/*margin-top: 2rem;*/
			width: 100%;
			text-align: center;
			font-size: 0.65rem;
			margin-top: 10rem;
			font-size: .65rem;
		}

		.aui-bg-linear {
			/*background: linear-gradient(-152deg, #ff00ff, #9b00ff);*/
			/*background: linear-gradient(270deg, #ff00ff, #9471da);*/
			/*background: linear-gradient(270deg, #ee02fd, #9972e6);*/
			background: rgba(0, 90, 147, 1) !important;
			/*border-radius:2.5rem;*/
		}

		.keys {
			color: rgba(114, 213, 239, .5) !important;
		}

		.btn-block {
			margin-top: 3.5rem;
		}

		.btn-block>div {
			width: 16.25rem;
			height: 2.25rem;
			line-height: 2.4rem;
			background: rgba(179, 206, 223, 1);
			border-radius: 0.3rem;
			text-align: center;
			font-family: PingFangSC-Regular;
			font-weight: 500;
			color: rgba(255, 255, 255, 1);
			font-size: .6rem;
			color: #fff;
			margin: 0 auto;
		}

		/*.hyaline {
			display: inline-block;
			width: 3rem;
			height: .4rem;
			background: linear-gradient(135deg, rgba(132, 229, 255, 1) 0%, rgba(107, 180, 255, 1) 100%, rgba(122, 174, 229, 1) 100%);
			border-radius: .1rem;
			opacity: 0.5;
			position: absolute;
			left: -.1rem;
			top: 1.3rem;
			z-index: -1;
		}*/

		.login_regist {
			font-size: 1.4rem;
			color: #222222;
			font-family: PingFangSC-Medium;
			font-weight: 500;
		}

		.Account_number {
			display: inline-block;
			width: 100%;
			height: 1.05rem;
			margin-top: 0rem;
			font-family: PingFangSC-Regular;
			font-weight: 400;
			font-size: .75rem;
		}

		.retrieve {
			height: none;
			padding: 0 1.25rem;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
			float: right;
		}

		.retrieve>div:nth-child(1) {
			text-align: left;
			font-weight: 400;
			font-size: 0.6rem;
			margin-right: 0.35rem;
			color: rgba(128, 128, 128, 1);
			font-family: PingFangSC-Regular;
		}

		.retrieve>div:nth-child(2) {
			text-align: right;
			color: #72D5EF;
			font-family: PingFangSC-Regular;
			font-weight: 400;
			font-size: .75rem;
		}

		.aui-content {
			margin-top: 3.2rem;
			z-index: 2;
		}

		.code {
			font-size: 0.75rem;
			font-family: PingFangSC-Regular;
			font-weight: 400;
			color: #005A93;
			opacity: 0.3;
		}

		.active_code {
			font-size: 0.75rem;
			font-family: PingFangSC-Regular;
			font-weight: 400;
			color: rgba(114, 213, 239, 1);
		}

		/*---------------------------*/

		.foot_info {
			height: 4.3rem;
			width: 100%;
			/*background-color:pink;*/
			/* position: absolute; */
			/* bottom: 0; */
			text-align: center;
			line-height: 2.5rem;
			color: #fff;
			margin-top: 1rem;
			/*border-top: 1px solid red;*/
		}

		.Third_party {
			width: 100%;
			/*background-color:red;*/
			height: 1.8rem;
			line-height: 1.5rem;
			text-align: left;
			padding: 0 1.25rem;
			font-size: .75rem;
			font-family: PingFangSC-Regular;
			font-weight: 400;
			color: rgba(102, 102, 102, 1);
		}

		.Third_party img {
			width: 1.9rem;
			border: 0.1rem solid #f6f6f6;
			border-radius: 50%;
			display: inline-block;
			margin-left: 1.35rem;
			background: #f6f6f6;
		}

		.Third_party>span {
			display: inline-block;
			margin: auto;
		}

		.aui-pull-left {
			margin-left: 1.25rem;
		}

		.register_footer {
			width: 100%;
			height: 100%;
			font-size: 0.7rem;
			font-family: PingFangSC-Regular;
			font-weight: 400;
			color: rgba(179, 179, 179, 1);
		}

		.register_footer>span {
			color: #005A93;
			font-weight: 500;
			margin-left: 0.15rem;
			margin-right: 0.15rem;
		}
	</style>
</head>

<body>
	<!-- 关闭按钮 -->
	<!-- <div id="aui-header" class="ming-bg-blue">
			<header class="aui-bar aui-bar-nav ming-bg-blue">
				<a class="aui-pull-left" tapmode onclick="close_win()" style="margin-left:1.3rem;margin-bottom:2rem;">
					<img class="btn-img-back" src="../../image/btn/btn-close-dark.png" />
				</a>
			</header>
		</div> -->

	<div class="aui-content" id="app" v-cloak="">
		<!-- 登录、注册上部分 -->
		<div style="padding-left:1.25rem;">
			<div class="aui-info" style="padding:0;margin:0;">
				<div style="position:relative;">
					<!-- 登录/注册 组件 -->
					<span :class="{'active':index=='0'}" class="login_regist" v-if="message=='yes'">登录</span>
					<span :class="{'active':index=='0'}" class="login_regist" v-if="message=='no'">注册</span>

					<!-- 登陆/注册 底部透明蓝 -->
					<!-- <span class="hyaline"></span> -->

					<!-- 立即 & 注册/登录 -->
					<div class="Account_number">
						<div style="display:inline-block;float:left;color:rgba(128,128,128,1);">您还没有账号？</div>
						<div class="" tapmode onclick="isflag()" style="display:inline-block;float:left;">
							<!-- tapindex(0) ===> 展示登陆界面 -->
							<div class="" v-if="message=='no'">
								<span style="display:inline-block;color:#005A93;font-weight:500;">点击登录</span>
							</div>
							<!-- tapindex(1) ===> 展示注册界面 -->
							<div class="" v-if="message=='yes'">
								<span style="display:inline-block;color:#005A93;font-weight:500;">点击注册</span>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

		<!-- 手机/密码部分 -->
		<div class="my-list">

			<div class="item flex-box-x" v-if="message=='no'">
				<div class="center col-xs-x flex-y-center">
					<label class="padding-r-15">个人会员<input class="aui-radio"
							style="height:0.9rem;width:0.9rem;line-height: 0.9rem;margin-top:0.2rem;margin-left:0.3rem;"
							type="radio" v-model="reg_type" value="0" /></label>
					<label class="padding-l-35" style="margin-left:0.5rem;">企业会员<input class="aui-radio"
							style="height:0.9rem;width:0.9rem;line-height: 0.9rem;margin-top:0.2rem;margin-left:0.3rem;"
							type="radio" v-model="reg_type" value="1" /></label>
				</div>
			</div>

			<!-- 输入手机号 模块-->
			<div class="aui-list-item- aui-border-b"
				style="position:relative;border-bottom:1px solid rgb(230, 230, 230, 0.6);">
				<div class="ming-pr" style="flex: 1;">
					<span
						style="line-height: 2.3rem;float: left;display: inline-table;font-size: 0.7rem;font-weight: 400;font-family: sans-serif;color: rgba(77,77,77,1);margin-right: 0.50rem;">+86</span><input
						v-model="mobile" type="tel" maxlength="11" placeholder="请输入手机号"
						style="width: 85%;font-size:0.68rem;font-family:PingFangSC-Regular;font-weight:400;color:rgba(34,34,34,1);" />
					<div style="width: 1.1rem;position:absolute;right:.2rem;bottom:.55rem;" tapmode @click="mobile=''">
						<img v-if="mobile!=''" src="../../image/btn/btn-search-delete.png" />
					</div>
				</div>
			</div>

			<!-- 短信验证码 模块 -->
			<div v-if="index=='1'" class="aui-list-item- aui-border-b"
				style="position:relative;font-size:0.75rem;font-family:PingFangSC-Regular;font-weight:400;color:rgba(34,34,34,1);border-bottom:1px solid rgb(230, 230, 230, 0.6);">
				<div class="ming-pr" style="flex: 1;">
					<input v-model="sms_code" type="tel" maxlength="6" placeholder="短信验证码"
						style="font-size: 0.68rem;" />

					<div style="position:absolute;right:.2rem;bottom:.55rem;" tapmode onclick="getCode()"
						v-if="mobile.length == 11">
						<span class="active_code">{{sms_time}}</span>
					</div>

					<div style="position:absolute;right:.2rem;bottom:.55rem;" v-else>
						<span class="code">{{sms_time}}</span>
					</div>

				</div>
			</div>

			<!-- 输入密码 模块 -->
			<div class="aui-list-item- aui-border-b"
				style="border-bottom:1px solid rgb(230, 230, 230, 0.6);position:relative;font-size:0.75rem;font-family:PingFangSC-Regular;font-weight:400;">
				<div class="ming-pr" style="margin-right:1rem;flex: 1;">

					<input v-if="index=='1'" v-model="pwd" v-bind:type.prop=type placeholder="请设置密码" maxlength="20"
						style="color:rgba(179,179,179,1);font-weight:400;font-size: 0.68rem;color:rgba(34,34,34,1);" />
					<input v-else v-model="pwd" v-bind:type.prop=type placeholder="请输入密码" maxlength="20"
						style="color:rgba(179,179,179,1);font-weight:400;font-size: 0.68rem;color:rgba(34,34,34,1);" />
					<!-- <img tapmode @click="pwd=''" v-if="pwd!=''" class="icon-clear" src="../../image/btn/btn-search-delete.png" /> -->
				</div>
				<div style="width: 1.1rem;position:absolute;right:.2rem;bottom:.7rem;" tapmode onclick='show_pwd()'>
					<img v-if="!is_show" style="display: inline-block;width: 1rem;vertical-align: middle;"
						src="../../image/icon/icon-noeye.png" />
					<img v-if="is_show" style="display: inline-block;width: 1rem;vertical-align: middle;"
						src="../../image/icon/icon-eye.png" />
				</div>
			</div>



			<!-- 填写邀请码 -->
			<div v-if="index=='1'" class="aui-list-item- aui-border-b"
				style="border-bottom:1px solid rgb(230, 230, 230, 0.6);position:relative;font-family:PingFangSC-Regular;font-weight:400;color:rgba(34,34,34,1);">
				<input type="text" v-model="nickname" placeholder="请填写用户名称/公司名" style="font-size:0.68rem;">
			</div>

			<!-- 填写邀请码 -->
			<div v-if="index=='1' && reg_type=='1'" class="aui-list-item- aui-border-b"
				style="height:4rem;margin-top:0.5rem;border-bottom:1px solid rgb(230, 230, 230, 0.6);position:relative;font-family:PingFangSC-Regular;font-weight:400;color:rgba(34,34,34,1);">
				<div style="color:rgba(34,34,34,0.3);">请上传公司营业执照</div>
				<div v-for="(vo,index) in imgpath" class="aui-col-xs-2 ming-pr" style="width:20%;margin-bottom:.8rem;">
					<img class="img" :src="vo" style="height:3rem;border-radius:0.2rem;">
					<img class="btn-delete" src="../../image/btn/btn-close-hui.png" tapmode @click="delimg(index)"
						style="width:0.8rem;">
				</div>
				<!-- 添加商品的图标 -->
				<div v-if="img==''" class="aui-col-xs-2 ming-pr" tapmode @click="sel_pic()" style="width:20%;">
					<img src="../../image/bg/addpicture.png" style="height:3rem;margin-bottom:.5rem;" />
				</div>
			</div>

			<!-- 填写邀请码 -->
			<div v-if="index=='1' && reg_type=='1'" class="aui-list-item- aui-border-b"
				style="border-bottom:1px solid rgb(230, 230, 230, 0.6);position:relative;font-family:PingFangSC-Regular;font-weight:400;color:rgba(34,34,34,1);">
				<input type="text" v-model="inviteCode" placeholder="请填写邀请手机号码(必填)" style="font-size:0.68rem;">
			</div>

			<!-- 填写邀请码 -->
			<div v-if="index=='1'&& reg_type=='0' " class="aui-list-item- aui-border-b"
				style="border-bottom:1px solid rgb(230, 230, 230, 0.6);position:relative;font-family:PingFangSC-Regular;font-weight:400;color:rgba(34,34,34,1);">
				<input type="text" v-model="inviteCode" placeholder="请填写邀请手机号码(必填)" style="font-size:0.68rem;">
			</div>

			<!-- 选择所在地 -->
			<div @click="showPopup" v-if="index=='1'" class="aui-list-item- aui-border-b"
				style="border-bottom:1px solid rgb(230, 230, 230, 0.6);position:relative;font-family:PingFangSC-Regular;font-weight:400;color:rgba(34,34,34,1);">
				<input type="text" readonly="readonly" v-model="regionId" placeholder="请选择你的所在地区"
					style="width: 90%;float: left;font-size:0.68rem;">
				<div class="" v-if="index=='1'" style="width: 1.5rem;height: 1.5rem;">
					<img src="../../image/icon/icon-Lopen.png" alt="" style="width: 1.5rem;height: 1.5rem;">
				</div>
			</div>
			<!-- <van-popup v-model="showw" position="bottom">
				<van-picker show-toolbar :columns="columns" @cancel="onCancel" @confirm="onConfirm" />
			</van-popup> -->
		</div>

		<!-- 忘记密码 模块	 -->
		<div v-show="index=='0'" class="retrieve">
			<!-- 快捷登陆 组件 -->
			<!-- <div tapmode onclick="open_win('login_phone','login_phone.html',false)">
				手机验证码登录
			</div> -->
			<!-- 忘记密码 组件 -->
			<div tapmode onclick="open_win('change_pwd','change_pwd.html',false)">
				忘记密码？
			</div>
		</div>

		<!-- 登录/注册按钮 -->
		<div class="btn-block" v-show="index=='0'">
			<div :class="{'aui-bg-linear':mobile!=''&&pwd!=''}" tapmode onclick="login()">
				登录
			</div>
		</div>
		<div class="btn-block" v-show="index=='1'" style="margin-top:2rem;">
			<div :class="{'aui-bg-linear':mobile!=''&&sms_code!=''&&pwd!=''}" tapmode onclick="reg()">
				注册
			</div>
		</div>

		<div class="foot_info">
			<div>
				<div class="register_footer">
					<img onclick="showDL_yonghu()"
						:src="!DLselect?'../../image/btn/unselected.png':'../../image/btn/selected.png'" alt="">
					<div class="agreement">
						登录注册需同意 <span tapmode onclick="open_win_page('用户协议')">用户协议</span> 和 <span tapmode
							onclick="open_win_page('隐私协议')">隐私协议</span>
					</div>
					<!-- <span v-else style="display: inline-block;width: 0.8rem;height: 0.56rem;margin-right: 0.2rem;"><img src="../../image/btn/selected.png" alt=""></span>登录注册需同意 -->
				</div>
			</div>
		</div>


	</div>
</body>

<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/vant.min.js"></script>
<script>
	var vm = new Vue({
		el: "#app",
		data: {
			reg_type: 0,
			img: 0,
			imgpath: [],
			show: false,
			flag: true,
			message: "yes",
			index: 0,
			mobile: '',
			nickname: '',
			pwd: '',
			sms_code: '',
			is_show: false,
			type: 'password',
			sms_time: '获取验证码',
			wechat_show: true,
			weibo_show: true,
			qq_show: true,
			flag: true,
			DLselect: false,
			ZCselect: false,
			cityvalue: null,
			cityvalueIndex: null,
			newcityvalue: null,
			showw: true,
			inviteCode: '',
			regionId: '',
			regionIdCode: '',
			columns: [],
			agree: false
		},
		methods: {
			delimg: function (index) {
				vm.img.splice(index, 1)
				vm.imgpath.splice(index, 1)
			},
			sel_pic: function () {
				getHasPermission('camera', function (ret) {
					if (ret) {
						getHasPermission('photos', function (ret) {
							if (ret) {
								getHasPermission('storage', function (ret) {
									if (ret) {
										select_pic(function (ret) {
											// alert(JSON.stringify(ret,true))
											post_img('api/UpFiles/upload', ret.data, function (ret) {
												vm.img = ret.data.pic_id;
												vm.imgpath.push(ret.data.url);
												//vm.video.push(ret.data.url);
											})
										})
									} else {
										toast('获取存储权限失败')
									}
								})
							} else {
								toast('获取相册权限失败')
							}
						})
					} else {
						toast('获取相机权限失败')
					}
				})
			},
			openMsgbox: function () {
				api.openFrame({
					name: 'yinsi_msgbox',
					url: 'widget://html/login/components/msgbox.html',
					bounces: false,
					vScrollBarEnabled: false,
					bgColor: 'rgba(0,0,0,0.5)',
					rect: {
						x: 0,
						y: 0,
						w: 'auto',
						h: 'auto'
					},
					pageParam: {}
				})
			},
			authThird: function () {
				var obj_qq = api.require('QQPlus');
				obj_qq.installed(function (ret, err) {
					if (ret.status) { } else {
						vm.qq_show = false;
					}
				});
				var obj_wx = api.require('wxPlus');
				obj_wx.isInstalled(function (ret, err) {
					if (ret.installed) { } else {
						vm.wechat_show = false;
					}
				});
				var sinaWeiBo = api.require('weiboPlus');
				sinaWeiBo.isInstalled(
					function (ret) {
						if (ret.status) { } else {
							vm.weibo_show = false;
						}
					}
				);
			},
			showPopup() {
				api.openFrame({
					name: 'setindustry_popup',
					url: '../components/setindustry_popup.html',
					bounces: false,
					vScrollBarEnabled: false,
					bgColor: 'rgba(0,0,0,0.5)',
					rect: {
						x: 0,
						y: 0,
						w: 'auto',
						h: 'auto'
					},
					animation: {
						type: "fade", //动画类型（详见动画类型常量）
						subType: "from_bottom", //动画子类型（详见动画子类型常量）
						duration: 300 //动画过渡时间，默认300毫秒
					}
				})
			},
			onCancel() {
				this.show = false;
			},

			//获取选择的城市
			onConfirm(value, index) {
				vm.cityvalue = value, //城市名
					vm.cityvalueIndex = index, //选择城市下表
					api.setPrefs({
						key: 'cityvalue',
						value: vm.cityvalue
					});
				this.show = false;
			},

		},
	})
	apiready = function () {
		// 监听勾选
		vm.agree = api.getPrefs({ sync: true, key: 'agree' });

		if (vm.agree == false) {
			// 监听勾选
			vm.openMsgbox()
		}
		// add_event('is_check', function (ret) {
		// 	if (ret.is_check) {
		// 		vm.DLselect = !vm.DLselect
		// 	}
		// });
		add_event('setaddress_popup', function (ret) {
			vm.regionId = ret.addressValue;
			vm.regionIdCode = ret.regionId;
		})
		// $api.fixStatusBar($api.byId('aui-header'))
		// $api.fixStatusBar($api.byId('aui-footer'))
		api.setStatusBarStyle({
			style: 'dark'
		});
		vm.authThird();
        if($api.getStorage('phone')){
			vm.mobile = $api.getStorage('phone');
		}
		if($api.getStorage('password')){
			vm.pwd = $api.getStorage('password');
		}
		

	};

	//登录/注册 隐私勾选
	function showDL_yonghu() {
		console.log(vm.DLselect)
		if (vm.DLselect == true) {
			vm.DLselect = false;
			send_event('is_check', {
				is_check: true
			})
		} else {
			vm.DLselect = true;
			send_event('is_check', {
				is_check: true
			})
		}
	}

	function getCode() {
		if (vm.mobile == '') {
			return;
		}
		if (vm.sended) {
			return;
		}
		get_data('api/Sms/sendAuthCode', {
			mobile: vm.mobile
		}, function (ret) {
			//从服务器请求验证码并返回结果，如果已发送操作如下：
			if (ret.status == '1') {
				vm.sended = 1;
				var timer = 60;
				vm.sms_time = timer + 's'
				var ti = setInterval(function () {
					timer = timer - 1;
					vm.sms_time = timer + 's';
					if (timer < 0) {
						vm.sended = 0;
						vm.sms_time = '获取验证码';
						clearInterval(ti);
					}
					if (timer == 50) {
						vm.sms_code = ret.data.auth_code;
					}
				}, 1000);


			}
			toast(ret.msg)
		})
	}

	function isflag() {
		vm.flag = !vm.flag
		if (vm.flag) {
			vm.message = "yes"
			tapindex(0)
			api.sendEvent({
				name: 'myEvent',
			});

		} else {
			vm.message = "no"
			tapindex(1)
			api.sendEvent({
				name: 'myEvent2',
			});
		}
	}


	function show_pwd() {
		vm.is_show = !vm.is_show
		if (vm.is_show) {
			vm.type = 'text'
		} else {
			vm.type = 'password'
		}
	}

	function tapindex(index) {
		if (vm.index != index) {
			vm.index = index
		}
	}

	function login() {
		// vm.DLselect = api.getPrefs({
		// 		sync: true,
		//     key: 'DLselect'
		// });
		if (vm.mobile == '' || vm.pwd == '') {
			return;
		} else if (!vm.DLselect) {
			toast('请您先勾选同意用户协议及隐私政策');
			return;
		}
		get_data('api/Login/login', {
			mobile: vm.mobile,
			password: vm.pwd
		}, function (ret) {
			toast(ret.msg)
			if (ret.status) {
				$api.setStorage('token', ret.data.token)
				$api.setStorage('phone', vm.mobile)
				$api.setStorage('password', vm.pwd)
				save_userinfo_new(ret)
				api.sendEvent({
					name: 'xg_push',
					extra: {
						uid: ret.data.id
					}
				});
				api.sendEvent({
					name: 'logined'
				});
				api.closeFrameGroup({
					name: 'IndexGroup'
				});

				send_event('return_cart', {
					index: 3
				})

				delay_close()
			}
		})
	}

	function reg() {

		// alert(vm.img)
		if (vm.mobile == '' || vm.pwd == '' || vm.sms_code == '') {
			return;
		} else if (!vm.DLselect) {
			alert('请您先勾选同意用户协议及隐私政策');
			return;
		} else if (vm.regionId == '') {
			alert('请选择地址');
			return;
		}

		if (vm.inviteCode == '') {
				alert('请填写邀请码');
				return;
		}

		if (vm.nickname == '') {
			alert('请填写名称/公司名');
			return;
		}

		if (vm.reg_type == 1) {
			
			if (vm.img == '') {
				alert('请上传营业执照');
				return;
			}
		}

		console.log(JSON.stringify({
			img: vm.img,
			reg_type: vm.reg_type,
			mobile: vm.mobile,
			authCode: vm.sms_code,
			password: vm.pwd,
			regionId: vm.regionIdCode,
			inviteCode: vm.inviteCode,
			nickname: vm.nickname,
		}))

		get_data('api/Login/register', {
			img: vm.img,
			reg_type: vm.reg_type,
			mobile: vm.mobile,
			authCode: vm.sms_code,
			password: vm.pwd,
			regionId: vm.regionIdCode,
			inviteCode: vm.inviteCode,
			nickname: vm.nickname,
		}, function (ret) {

			// console.log(JSON.stringify(ret))


			if (ret.status == 1) {

				alert(ret.data.message)
				$api.setStorage('token', ret.data.token)
				save_userinfo_new(ret)
				api.sendEvent({
					name: 'xg_push',
					extra: {
						uid: ret.data.id
					}
				});
				send_event('logined')
				delay_close()
			} else {
				alert(ret.msg)
			}
		})
	}

	function login_q() {
		login_qq(function (ret) {
			var qq = api.require('QQPlus');
			var openid = ret.openId;
			qq.getUserInfo(function (ret, err) {
				if (ret.status) {
					var info = ret.info
					login_bind(openid, 'qq', info.nickname)
				} else { }
			});
		}, function (error) {
			vm.qq_show = false;
		})
	}

	function login_w() {
		login_wechat(function (ret) {
			var wx = api.require('wxPlus');
			var openid = ret.openId;
			wx.getUserInfo({
				accessToken: ret.accessToken,
				openId: openid
			}, function (ret, err) {
				if (ret.status) {
					login_bind(openid, 'wx', ret.nickname)
					//						alert(JSON.stringify(ret));
				} else {
					alert(err.code);
				}
			});
		}, function (error) {
			vm.wechat_show = false;
		})
	}

	function login_sina() {
		login_wb(function (ret) {
			var openid = ret.userId;
			var token = ret.token;
			login_bind(openid, 'sina', openid)
			return;
			//alert(JSON.stringify(ret))
			var weibo = api.require('weiboPlus');
			weibo.getUserInfo({
				token: token,
				userId: openid
			}, function (ret, err) {
				//alert(token + '/' + openid)
				if (ret.status) {
					//alert(JSON.stringify(ret));
					login_bind(openid, 'sina', info.nickname)
				} else {
					alert(JSON.stringify(err));
				}
			});
		}, function (error) {
			vm.weibo_show = false;
		})
	}
	//sina 微博登录的flag
	function login_bind(openId, flag, name) {
		get_data('api/login/isBindMobile', {
			openid: openId,
			flag: flag
		}, function (ret) {
			if (ret.status == '1') {
				$api.setStorage('token', ret.data.token)
				save_userinfo_new(ret)
				send_event('logined')
				setTimeout(function () {
					close_win()
				}, 300);
			} else {
				toast(ret.msg)
				$api.setStorage('bindinfo', {
					openid: openId,
					flag: flag,
					name: name
				})
				open_win('bind', 'bind.html', false)
				setTimeout(function () {
					close_win()
				}, 1000);
			}
		})
	}


	function login_bind(openId, flag, name) {
		get_data('api/login/quickBindUser', {
			token: $api.getStorage('token'),
			openid: openId,
			third_username: name,
			flag: flag
		}, function (ret) {
			if (ret.status) {
				toast('绑定成功')
				vm.get_userinfo()
			} else {
				toast(ret.msg)
			}
		})
	}
</script>

</html>